package com.gin.kotlin.no_gay_alliance.fragment.main.usercenter

import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.gin.kotlin.no_gay_alliance.activity.UserCenterActivity
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingFragment
import com.gin.kotlin.no_gay_alliance.model.UserDetailModel

abstract class AbstractUserCenterTabFragment<T : ViewBinding> : AbstractBindingFragment<T> {
    protected lateinit var userDetail: UserDetailModel

    constructor() : super()
    constructor(data: UserDetailModel? = null) : super() {
        this.arguments = Bundle().also { it.putParcelable(KEY, data) }
    }

    override fun handleArguments(bundle: Bundle) {
        this.userDetail = parseBundle(bundle, KEY, UserDetailModel::class.java)
    }

    override fun onResume() {
        super.onResume()
        (requireActivity() as? UserCenterActivity)?.also { it.currentFragment = this }
    }

    companion object {
        private val KEY = UserCenterActivity.KEY_ARGUMENT
    }
}